var t = getApp();

Page({
    data: {
        motto: "Hello World",
        userInfo: {},
        weight: "",
        height: "",
        result_num: "",
        hasUserInfo: !1,
        canIUse: wx.canIUse("button.open-type.getUserInfo"),
        listData: [ {
            code: "偏瘦",
            text: "<= 18.4"
        }, {
            code: "正常",
            text: "18.5 ~ 23.9"
        }, {
            code: "过重",
            text: "24.0 ~ 27.9"
        }, {
            code: "肥胖",
            text: ">= 28.0"
        } ]
    },
    bindViewTap: function() {
        wx.navigateTo({
            url: "../logs/logs"
        });
    },
    onLoad: function() {
        var e = this;
        t.globalData.userInfo ? this.setData({
            userInfo: t.globalData.userInfo,
            hasUserInfo: !0
        }) : this.data.canIUse ? t.userInfoReadyCallback = function(t) {
            e.setData({
                userInfo: t.userInfo,
                hasUserInfo: !0
            });
        } : wx.getUserInfo({
            success: function(s) {
                t.globalData.userInfo = s.userInfo, e.setData({
                    userInfo: s.userInfo,
                    hasUserInfo: !0
                });
            }
        });
    },
    getUserInfo: function(e) {
        console.log(e), t.globalData.userInfo = e.detail.userInfo, this.setData({
            userInfo: e.detail.userInfo,
            hasUserInfo: !0
        });
    },
    listenerWeight: function(t) {
        this.data.weight = t.detail.value;
    },
    listenerHeight: function(t) {
        this.data.height = t.detail.value;
    },
    getResult: function() {
        var t, e;
        return this.setData({
            result_num: "",
            result_big: ""
        }), "" == this.data.weight ? (t = "输入体重", void this.setData({
            result_num: t
        })) : "" == this.data.height ? (t = "输入身高", void this.setData({
            result_num: t
        })) : (t = this.data.weight / (this.data.height * this.data.height / 1e4), isNaN(t) ? (t = "检测错误", 
        void this.setData({
            result_num: t
        })) : (t <= 18.4 ? e = "  偏廋，加强营养" : t > 18.4 && t <= 23.9 ? e = "  正常，继续保持" : t > 24 && t <= 27.9 ? e = "  过重，加强锻炼" : t >= 28 && (e = "  肥胖，吃动平衡"), 
        void this.setData({
            result_num: t.toFixed(2),
            result_big: e
        })));
    }
});